import java.util.Scanner;
// https://www.acwing.com/problem/content/5/
public class bag04 {
    static int [] v1 = new int[20010];
    static int [] w1 = new int[20010];
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int v = sc.nextInt();
        int cnt = 1;
        for(int i = 0 ; i < n ; i ++ )
        {
            int vi = sc.nextInt();
            int wi = sc.nextInt();
            int si = sc.nextInt();

            for(int t = 1 ; t <= si ; t <<= 1)
            {
                v1[cnt] = t * vi;
                w1[cnt] = t * wi;
                si -= t;
                cnt ++;
            }

            if(si > 0)
            {
                v1[cnt] = si * vi;
                w1[cnt] = si * wi;
                cnt++;
            }
        }

        int [] dp = new int [v + 2];
        for(int i = 1 ; i  <  cnt ; i ++)
        {
            for(int j = v ; j >= v1[i] ; j --)
            {
                dp[j] = Math.max(dp[j],dp[j - v1[i]] + w1[i]);
            }
        }

        System.out.println(dp[v]);
    }

}
